import { isFunction } from './is';

const rawHasOwn = (function () {
	if (Object.hasOwn && isFunction(Object.hasOwn)) {
		return Object.hasOwn;
	} else {
		const hasOwnProp = Object.prototype.hasOwnProperty;
		return function () {
			hasOwnProp.call(...arguments);
		};
	}
})();

/**
 * 判断对象上是否有指定属性（不包含原型链上的属性）
 * @param {any} target
 * @param {string} propname
 * @returns {boolean}
 */
export const hasOwn = (target, propname) => {
	return rawHasOwn(target, propname);
};
